package com.welsy.usermgt.business
{
	import com.welsy.usermgt.vo.SearchVO;
	import mx.controls.Alert;
	import com.welsy.usermgt.vo.UserVO;
	import com.adobe.cairngorm.business.ServiceLocator;
	import mx.rpc.soap.mxml.WebService;
	import mx.rpc.AbstractOperation;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.logging.Log;
	
	public class RemoveUserDelegate 
	{
		private var responder : IResponder;
		private var service : Object;
		
		public function RemoveUserDelegate( responder : IResponder ) {
			//Recorded in Services.mxml
			this.responder = responder;
			this.service = ServiceLocator.getInstance().getWebService("UserMgtService") as WebService;
		}
		
		/**
		 * This method manages the query to the database
		 * It receives back an XMLList and does troubleshooting  
		 **/
		public function performRemove(userVO : UserVO):void {
			//Send the request to the server...
			var op : AbstractOperation = service.getOperation("RemoveUser");
			op.arguments.RemoveUserRequest.UserId = userVO.UserId;
			op.arguments.RemoveUserRequest.FirstName = userVO.FirstName;
			op.arguments.RemoveUserRequest.LastName = userVO.LastName;
			op.arguments.RemoveUserRequest.Login = userVO.Login;
			op.arguments.RemoveUserRequest.Email = userVO.Email;
			op.arguments.RemoveUserRequest.SubSystemId = userVO.SubSystemId;
			op.arguments.RemoveUserRequest.RoleId = userVO.RoleId;

			var token : AsyncToken = service.RemoveUser();
			token.addResponder(responder);
		}		
	}
}